/**
 * app权限说明
 */

import {
	usePermission
} from "../stores/permission.js"


export const uploadImg = async (config) => {
	
	// #ifdef APP-PLUS
	const permissionStore = usePermission()
	if (!await permissionStore.requstPermission('CAMERA')) return
	//选择照片这个是摄像头和相册 多个权限 那么在这写两次就好了
	//if (!await permissionStore.requstPermission('CAMERA')) return
	//if (!await permissionStore.requstPermission('READ_EXTERNAL_STORAGE')) return
	// #endif
	return new Promise((resolve, reject) => {
        config = config || {};
		const count = config.count ?? 1;
		const sizeType = config.sizeType ?? ['original', 'compressed'];
		const sourceType = config.sourceType ?? ['album', 'camera'];
		uni.chooseImage({
			count: count,
			sizeType: sizeType,
			sourceType: sourceType,
			success: (res) => {
				resolve(res.tempFilePaths)
			},
			fail: (res) => {
				reject(res)
			},
			complete: (res) => {
				console.log(res)
			}
		});
	})
}